﻿using System.Collections.Generic;

namespace ElectronicCommerce.Framework.Data.Entity.EntityQueryCondition
{
    public class Range<T, N>
    {
        /// <summary>
        /// Range
        /// </summary>
        public Range()
        {
        }

        /// <summary>
        /// Range
        /// </summary>
        /// <param name="value"></param>
        /// <param name="operatorValue"></param>
        public Range(T value, N operatorValue)
        {
            Value = value;
            Operator = operatorValue;
        }

        /// <summary>
        /// Range
        /// </summary>
        /// <param name="startValue"></param>
        /// <param name="endValue"></param>
        /// <param name="operatorValue"></param>
        public Range(T startValue, T endValue, N operatorValue)
        {
            Start = startValue;
            End = endValue;
            Operator = operatorValue;
        }

        /// <summary>
        /// 当设置为Between时,该字段必须赋值
        /// </summary>
        /// <value>The start.</value>
        public T Start { get; set; }

        /// <summary>
        /// 当设置为Between时,该字段必须赋值
        /// </summary>
        /// <value>The end.</value>
        public T End { get; set; }

        /// <summary>
        /// 当设置为非Between时,该字段必须赋值
        /// </summary>
        /// <value>The value.</value>
        public T Value { get; set; }

        /// <summary>
        /// 设置查询条件,默认等于.该值为Between时,Start和End字段必须赋值,该值为非Between时,Value字段必须赋值.
        /// </summary>
        /// <value>The operator.</value>
        public N Operator { get; set; }

        /// <summary>
        /// 别名 多表查询的时候建议设置.
        /// </summary>
        public string Alias { get; set; }

        /// <summary>
        /// 当设置为In的时候，必须设置该字段，
        /// 该字段新加，请确认相关条件是否实现。
        /// </summary>
        public List<T> ListValue { get; set; }

        #region 暂时不可用
        ///// <summary>
        ///// 或
        ///// </summary>
        ///// <param name="left">左侧条件</param>
        ///// <param name="right">右侧条件</param>
        ///// <returns></returns>
        //public static Range<T, N> operator |(Range<T, N> left, Range<T, N> right)
        //{
        //    //QueryBuildHelper.SqlGetConditionStr(left,left.)
        //    return null;
        //}

        ///// <summary>
        ///// 与
        ///// </summary>
        ///// <param name="left">左侧条件</param>
        ///// <param name="right">右侧条件</param>
        ///// <returns></returns>
        //public static Range<T, N> operator &(Range<T, N> left, Range<T, N> right)
        //{
        //    return null;
        //}
        #endregion
    }
}
